<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest:admin')->except('logout');
    }
    public function username()
    {
        return 'name';
    }
    public function showLoginForm()
    {
        return view('login');
    }
    protected function guard()
    {
        return auth()->guard('admin');
    }

    /**
     * @return 退出
     */
    public function logout()
    {
        if ($this->guard()->user()) {
            $this->guard()->logout();
        }

        return redirect('/login');
    }
}
